﻿using GalaSoft.MvvmLight.Messaging;
using NicoView.ViewModel.Message;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interactivity;

using Message = GalaSoft.MvvmLight.Messaging.NotificationMessage;

namespace NicoView.View.Behaviors
{
    public class NotificationMessageTrigger : TriggerBase<MainWindow>
    {
        protected override void OnAttached()
        {
            base.OnAttached();

            Messenger.Default.Register<Message>(AssociatedObject, 
                msg => 
                    InvokeActions(msg)
                );
        }

        protected override void OnDetaching()
        {
            Messenger.Default.Unregister<Message>(AssociatedObject);

            base.OnDetaching();
        }
    }
}
